package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.StreetCommunity;
import com.ruoyi.system.service.IStreetCommunityService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * street_communityController
 * 
 * @author ruoyi
 * @date 2025-11-22
 */
@RestController
@RequestMapping("/system/streetCommunity")
public class StreetCommunityController extends BaseController
{
    @Autowired
    private IStreetCommunityService streetCommunityService;

    /**
     * 查询街道填报数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:streetCommunity:list')")
    @GetMapping("/list")
    public TableDataInfo list(StreetCommunity streetCommunity)
    {
        startPage();
        List<StreetCommunity> list = streetCommunityService.selectStreetCommunityList(streetCommunity);
        return getDataTable(list);
    }
    /**
     * 查询街道填报数据列表
     */
    @GetMapping("/listAll")
    public List<StreetCommunity> listAll(StreetCommunity streetCommunity)
    {
        List<StreetCommunity> list = streetCommunityService.selectStreetCommunityList(streetCommunity);
        return list;
    }
    /**
     * 导出街道填报列表
     */
    @PreAuthorize("@ss.hasPermi('system:streetCommunity:export')")
    @Log(title = "街道填报", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StreetCommunity streetCommunity)
    {
        List<StreetCommunity> list = streetCommunityService.selectStreetCommunityList(streetCommunity);
        ExcelUtil<StreetCommunity> util = new ExcelUtil<StreetCommunity>(StreetCommunity.class);
        util.exportExcel(response, list, "街道填报数据");
    }

    /**
     * 获取街道详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:streetCommunity:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(streetCommunityService.selectStreetCommunityById(id));
    }

    /**
     * 新增街道填报数据
     */
    @PreAuthorize("@ss.hasPermi('system:streetCommunity:add')")
    @Log(title = "街道填报", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StreetCommunity streetCommunity)
    {

        return toAjax(streetCommunityService.insertStreetCommunity(streetCommunity));
    }

    /**
     * 修改街道填报数据
     */
    @PreAuthorize("@ss.hasPermi('system:streetCommunity:edit')")
    @Log(title = "街道填报", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StreetCommunity streetCommunity)
    {
        return toAjax(streetCommunityService.updateStreetCommunity(streetCommunity));
    }

    /**
     * 删除街道填报数据
     */
    @PreAuthorize("@ss.hasPermi('system:sstreetCommunity:remove')")
    @Log(title = "街道填报", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(streetCommunityService.deleteStreetCommunityByIds(ids));
    }
}
